package com.itawei.d3_io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class ByteStreamDemo7 {
    public static void main(String[] args) throws IOException {
        //1.创建对象
        FileInputStream fis = new FileInputStream("day06-file-io\\a.txt");
        //2.读取数据
        byte[] bytes = new byte[2];
        //一次读取多个字节数据，具体读多少，跟数组的长度有关
        //返回值，本次读取到了多少个字节数据

        int len1 = fis.read(bytes);//len记录一次读了几个
        System.out.println(len1);//2
        String s1 = new String(bytes, 0, len1);
        System.out.println(s1);

        int len2 = fis.read(bytes);//len记录一次读了几个
        System.out.println(len2);//2
        String s2 = new String(bytes, 0, len2);
        System.out.println(s2);

        int len3 = fis.read(bytes);//len记录一次读了几个
        System.out.println(len3);//1
        String s3 = new String(bytes,0 ,len3 );
        System.out.println(s3);

        fis.close();


    }
}
